package com.example.rbac.handle;

import org.apache.shiro.authz.AuthorizationException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * Created by Administrator on 2017/10/12.
 */

/**
 * 处理shiro权限出现的异常
 */
@ControllerAdvice
public class AuthControllerAdvices {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());
    @ExceptionHandler(value = AuthorizationException.class)
    public String error() {
       logger.info("===========应用到所有@RequestMapping注解的方法，在其抛出AuthorizationException异常时执行");
        return "error"; //返回一个逻辑视图名
    }

    @ExceptionHandler(value = IllegalArgumentException.class)
    public String ArgumentException(){
        return "error";
    }

}
